package com.lagou.nio;

import java.nio.IntBuffer;

public class NioBuffer {

    public static void main(String[] args) {

        // 初始化 IntBuffer, 容量为 5
        IntBuffer allocate = IntBuffer.allocate(5);

        // 写数据
        for (int i = 0; i < allocate.capacity(); i++) {
            allocate.put(i * 10);
        }

        // 切换为读模式
        allocate.flip();

        // 读数据
        while (allocate.hasRemaining()) {
            System.out.println(allocate.get());
        }
    }
}
